let config = {
	header: {
		'content-type': 'application/json;charset=UTF-8',
		// 'content-type': 'application/x-www-form-urlencoded',
	},
	url: 'https://apishop.qiancdj.com',
}

const install = (Vue, vm) => {
	Vue.prototype.$u.http.setConfig({
		baseUrl: config.url,
	});
	Vue.prototype.$u.http.interceptor.request = (config) => {
		config.header.token = uni.getStorageSync('userInfo')['shop_token']
		// config.header.token ='dd146d9c-5f43-4f3e-91dd-3603f6601b32'
		// config.header.token ='fa72c872-4ec3-416c-846f-5eaa1bd6c790'
		// config.header.token ='fa72c872-4ec3-416c-846f-5eaa1bd6c790'
		// config.header.token ='9d88a189-3758-4535-a48e-de6b9b360041'
		// config.header.token = "5f5a0da8-4fa6-4a71-ae75-5c7916b2a9d3"
		// config.header.token = "76cc7ae5-1e1f-4715-89c8-23fc7b22f082"
	}

	Vue.prototype.$u.http.interceptor.response = (res) => {
		if (res.code == 6) {
			uni.$u.toast('请先登录')
			setTimeout(function() {
				uni.reLaunch({
					url: '/pages/index/login'
				})
			}, 1500);
			return;
		} else if(res.code==0) {
			if(res.msg=='门店不存在'){
				uni.redirectTo({
					url:'/yCreate/pages/cooperation'
				})
			}else{
				return res;
			}
			
		}else{
			return res;
		}
	}
}
export default {
	install
}